
<%var csstpl = {%>
    <link href="${basepath}/vendor/css/font-awesome.min93e3.css?v=4.4.0" rel="stylesheet">
    <link href="${basepath}/vendor/css/plugins/iCheck/custom.css" rel="stylesheet">
    <link href="${basepath}/vendor/css/plugins/chosen/chosen.css" rel="stylesheet">
    <link href="${basepath}/vendor/css/style.min862f.css?v=4.1.0" rel="stylesheet">
    <link href="${basepath}/vendor/script/select2/css/select2.css" rel="stylesheet">
    <style>
    	* { outline:none; }
    	li { list-style:none; }
    	body { overflow-x:visible; }
    	.hide { display:none; }
    	.clear { clear:both; margin:0; }
    	.nav-tabs li a { min-width:300px; background:#fbfbfb; color:#555; text-align:center; border: 1px solid #e7eaec; }
    	.tabs-container .nav-tabs>li a:hover { background:#fff; border: 1px solid #e7eaec; }
    	
    	table.page { width:100%; } 
    	table.page td { padding:20px; background:#f8f8f8; border: 2px solid #fff; vertical-align:top; }
    	table.page td.tb_title { width:280px; padding-top:27px; font:bold 14px/1em "微软雅黑"; color:#333; text-align:center; }
    	table.page td.btns { text-align:center; }
    	
    	table.store { width:100%; border: 1px solid #e5e5e5; }
    	table.store td { padding:10px; background:#fff; border: 1px solid #e5e5e5; vertical-align:middle; }
    	table.store td img { width:40px; cursor:pointer; }
    	table.store td input { width:60px; padding:5px; border:1px solid #ddd; border-radius:5px; }
    	table.store td.btns { text-align:center; }
    	table.store tr.setting td { background:#fcfcfc !important; border-left:none; border-right:none; }
    	
    	.form-group .radio input { display:none; }
    	.form-group .radio i { display:block; width:20px; height:20px; position:absolute; left:15px; top:6px; background:url(${basepath}/vendor/css/plugins/iCheck/green.png) -120px 0; }
    	.form-group .radio:hover i { background:url(${basepath}/vendor/css/plugins/iCheck/green.png) -144px 0; }
    	.form-group .radio.active i { background:url(${basepath}/vendor/css/plugins/iCheck/green.png) -168px 0; }
    	.form-group .form-control  { border-radius:5px; width:210px; }
    	.form-group .descp { position:absolute; left:240px; top:10px; }
    	.chosen-choices2 { border-radius:3px !important; border:1px solid #e5e6e7 !important; }
    	.chosen-single2  { border-radius:3px !important; border:1px solid #e5e6e7 !important; }
    	
    	.pro_norms ul { padding:0; background:#fff; border:1px solid #e5e5e5; border-radius:5px; }
    	.pro_norms ul li { position:relative; min-height:50px; margin-bottom:-1px; padding:10px 60px 10px 220px; list-style:none inside; border-bottom:1px solid #e5e5e5; }
    	.pro_norms ul li .btn_delitem { position:absolute; right:0px; top:10px; }
    	.pro_norms ul li .btn_additem { position:absolute; left:0px; top:10px; }
    	.pro_norms ul li .btn_add { float:left; }
    	.pro_norms ul li .select2 { position:absolute; left:10px; }
    	.pro_norms ul li select { width:200px; }
    	.pro_norms ul li .item { position:relative; float:left; min-width:120px; margin-right:10px; padding:5px; text-align:center; border:1px solid #e5e5e5; border-radius:5px; }
    	.pro_norms ul li .item .btn_del { float:right; width:25px; height:15px; margin-left:5px; background:url(${basepath}/vendor/img/delete.png) no-repeat center; border-left:1px solid #e5e5e5; cursor:pointer; opacity:0.6; }
    	.pro_norms ul li .item .btn_del:hover { opacity:1; }
    	
    	.norm_contt select { width:100%; }
    	.norm_panel select { width:100%; }
    	.select2-dropdown { z-index:1000000000; }
    	.error { border:1px solid #f33 !important; }
    	.switch { margin-top:5px; }
    	
    	.pro_pic .pic { position:relative; margin:0 0 15px; padding:0; }
    	.pro_pic .pic:after { display:block; content:""; clear:both; }
		.pro_pic .pic li { position:relative; float:left; margin-right:5px; }
		.pro_pic .pic li b { position:absolute; right:-8px; top:-8px; z-index:5; display:block; width:26px; height:26px; background:#fff; border-radius:50%; cursor:pointer; }
		.pro_pic .pic li b img { position:absolute; left:2px; bottom:2px; display:block; width:22px; height:22px; }
		.pro_pic .pic li input { display:none; }
		.pro_pic .pic li img { width:80px; height:80px; border-radius:5px; opacity:0.9; }
		.pro_pic .pic .btn_add { cursor:pointer; }
		.pro_pic .pic .btn_add:active:after { border:1px solid #bbb; background:rgba(0,0,0,0.03); }
		.pro_pic .clear { line-height:40px; }
		
		.pro_banner .pic { position:relative; margin:0 0 15px; padding:0; }
    	.pro_banner .pic:after { display:block; content:""; clear:both; }
		.pro_banner .pic li { position:relative; float:left; margin:0 5px 5px 0; }
		.pro_banner .pic li b { position:absolute; right:-8px; top:-8px; z-index:5; display:block; width:26px; height:26px; background:#fff; border-radius:50%; cursor:pointer; }
		.pro_banner .pic li b img { position:absolute; left:2px; bottom:2px; display:block; width:22px; height:22px; }
		.pro_banner .pic li input { display:none; }
		.pro_banner .pic li img { width:150px; height:80px; border-radius:5px; opacity:0.9; }
		.pro_banner .pic .btn_add { cursor:pointer; }
		.pro_banner .pic .btn_add:active:after { border:1px solid #bbb; background:rgba(0,0,0,0.03); }
		.pro_banner .pic .btn_add img { width:80px; }
		.pro_banner .clear { line-height:40px; }
		
		.pro_pic2 .pic { position:relative; margin:0 0 15px; padding:0; }
    	.pro_pic2 .pic:after  { display:block; content:""; clear:both; }
		.pro_pic2 .pic li { position:relative; float:left; margin:0 5px 5px 0; }
		.pro_pic2 .pic li b { position:absolute; right:-8px; top:-8px; z-index:5; display:block; width:26px; height:26px; background:#fff; border-radius:50%; cursor:pointer; }
		.pro_pic2 .pic li b img { position:absolute; left:2px; bottom:2px; display:block; width:22px; height:22px; }
		.pro_pic2 .pic li input { display:none; }
		.pro_pic2 .pic li img { width:80px; height:80px; border-radius:5px; opacity:0.9; }
		.pro_pic2 .pic .btn_add { cursor:pointer; }
		.pro_pic2 .pic .btn_add:active:after { border:1px solid #bbb; background:rgba(0,0,0,0.03); }
		.pro_pic2 .clear { line-height:40px; }
		
		.panel2 h2 { font:30px/1em "微软雅黑"; color:#999; text-align:center; padding:200px 0; }
		.pro_recommend div { position:relative; }
		.pro_recommend textarea { width:210px; max-width:210px; min-height:8em; }
		.pro_recommend p { position:absolute; left:240px; top:10px; }
		.pro_percent div  { position:relative; }
		.pro_percent span { position:absolute; left:240px; top:10px; }
		
    	
    </style>
<%};%>
<%var jstpl = {%>
	<script src="${basepath}/plug/support.js"></script>
	
<script>

$(function(){
/* 	$(".btn_next").click(function(){
		var input_password  =$("#input_password").val();
		var product_id  =$("#product_id").val();
		if(input_password=="" || product_id=="" ){
			gx.alert("参数不能为空！");
			return ;
		}
		gx.load();
		gx.ajax("/shangjia/product/fetch/start_get?input_password="+input_password+"&product_id="+product_id,function(d){
			layer.closeAll();
			if(d.state){
				alert("商品抓取成功，马上跳转商品编辑页面 请仔细分类和对比商品！")
				window.location.href="/shangjia/product/edit/"+d.data;
				return ;
			}else{
				gx.alert(d.msg);
			}
		})
		
	}) */
	
	$(".btn_next").click(function(){
		var input_password  =$("#input_password").val();
		var product_id  =$("#product_id").val();
		if(input_password=="" ){
			gx.alert("参数不能为空！");
			return ;
		}
		gx.load();
		gx.post("/shangjia/product/fetch/start_get_v2","form_submit",function(d){
			layer.closeAll();
			if(d.state){
				alert(d.msg);
				//alert("商品抓取成功，马上跳转商品编辑页面 请仔细分类和对比商品！")
				//window.location.href="/shangjia/product/edit/"+d.data;
				return ;
			}else{
				gx.alert(d.msg);
			}
		})
		
	})
})

var init_state= false; 		
$(function(){
gx.ajax("/shangjia/product/type_json/${product.type_id!}",function(d){
	  if(d.state){
		  $("#type_sub_one_id").empty();
		  for(var i = 0; i<d.data.length;i++){
			  $("#type_sub_one_id").prepend("<option value='"+d.data[i].id+"'>"+d.data[i].type_name+"</option>")
		  }
		  if(init_state==false){
			  $("#type_sub_one_id").val("${product.type_sub_one_id!}")
			  $("#type_sub_one_id").change();
		  }
	  }
})

$("#type_id").change(function(e){
	gx.ajax("/shangjia/product/type_json/"+$("#type_id").val(),function(d){
		  if(d.state){
			  $("#type_sub_one_id").empty();
			  for(var i = 0; i<d.data.length;i++){
				  $("#type_sub_one_id").prepend("<option value='"+d.data[i].id+"'>"+d.data[i].type_name+"</option>")
			  }
			  $("#type_sub_one_id").change();
		  }
	})
})


$("#type_sub_one_id").change(function(e){
	gx.ajax("/shangjia/product/type_json/"+$("#type_sub_one_id").val(),function(d){
		  if(d.state){
			  $("#type_sub_two_id").empty();
			  for(var i = 0; i<d.data.length;i++){
				  $("#type_sub_two_id").prepend("<option value='"+d.data[i].id+"'>"+d.data[i].type_name+"</option>")
			  }
			  
			  if(init_state==false){
				  $("#type_sub_two_id").val("${product.type_sub_two_id!}")
			  }
		
		  }
	})
})

$("#fetch_type").change(function(e){
	if($(this).val()=="1"){
		$(".div_fetch_address").hide();
		$("#product_url").val("");
		$(".div_product_id").show();
		$("#product_id").val("");
	}else{
		console.info("div_fetch_address")
		$(".div_fetch_address").show();
		$("#product_url").val("");
		$(".div_product_id").hide();
		$("#product_id").val("");
	}
})
})
</script>
<%};%>
<%layout("../layout/_layout.html",{title:'研发测试',jstpl:jstpl,csstpl:csstpl}){ %>
<div class="wrapper wrapper-content animated fadeInRight">
	<div class="tabs-container">
        <ul class="nav nav-tabs">
            <li class="active"><a data-toggle="tab" href="#tab-1" aria-expanded="true">抓取商品信息</a></li>
            <li class=""><a data-toggle="tab" href="#tab-2" aria-expanded="false">选择商品模板</a></li>
        </ul>
        <div class="tab-content">
            <div id="tab-1" class="tab-pane active">
                <div class="panel-body">
                <form  id="form_submit" class="form-horizontal" method="post"  action="/shangjia/product/save">
                <table class="page">
                <tr>
	              <td class="tb_title">商品信息</td>
	              <td>
	              <div class="alert alert-warning">此功能是管理员专用</div>
     <!--                attr_type  属性类型 1拼团商品 2抽奖商品 3免团商品
     						
     
      -->
                    
                    <div class="form-group">
                    <label class="col-sm-2 control-label">商品类型</label>
                    <div class="col-sm-10">
                     <#select attr=' data-rule="required"  id="attr_type"   name="product.attr_type"   tabindex="2"  class="form-control pro_cate"'  value="1"  listdata="${@AppConst.Product_Attr_Type}"  />
                    </div>
                    </div>
                    
                    <div class="form-group">
                      <label class="col-sm-2 control-label">商品分类</label>
                      <div class="col-sm-10">
                      <!-- 商品分类 -->
                      <#select attr=' data-rule="required"  id="type_id"   name="product.type_id"   tabindex="2"  class="form-control pro_cate" '  value="${product.type_id!+''}"  listdata="${type_list!}" text="type_name" key="id" />
                       <select  data-rule="required"  id="type_sub_one_id" name="product.type_sub_one_id" class="form-control type_sub_one_id" >
								<option value="">请选择</option>
						</select>
                      	<select data-rule="required"  id="type_sub_two_id" name="product.type_sub_two_id" class="form-control type_sub_two_id" >
								<option value="">请选择</option>
						</select> 
                      <code style="margin-top: 6px" class="clear">请严格按照商铺类型选择商铺类型，如果选择错误可能商品会自动下线！</code>
                      </div>
                    </div>
                    
                    <div class="form-group">
                    <label class="col-sm-2 control-label">商品ID</label>
                    <div class="col-sm-10">
                    	<select   id="fetch_type" name="fetch_type" class="form-control " >
								<option value="">请选择</option>
								<option value="1" selected="">商品ID抓取</option>
								<option value="2">批量抓取</option>
						</select> 
                    </div>
                    </div>
                    
                    <div class="form-group div_product_id">
                    <label class="col-sm-2 control-label">商品ID</label>
                    <div class="col-sm-10"><input type="text" id="product_id" name="product.source_product_id" class="form-control pro_name"></div>
                    </div>
                    
                   <div class="form-group div_fetch_address" style="display: none;">
                    <label class="col-sm-2 control-label">商品地址</label>
                    <div class="col-sm-10"><input type="text" id="product_url" name="product_url" class="form-control pro_name"></div>
                    </div>
                    
                     <div class="form-group">
                    <label class="col-sm-2 control-label">Code</label>
                    <div class="col-sm-10">
                    <input type="text" id="is_check" name="is_check" value="1" class="form-control is_check">
                     <code >1.检查商品是否重复  2.不检查ID是否被抓</code>
                    </div>
                   
                    
                    </div>
                    
                    
	                <div class="form-group prices">
                    <label class="col-sm-2 control-label">校验密码</label>
                    <div class="col-sm-10">
                      <input type="text"  id="input_password" name="input_password" class="form-control" /><span class="descp">内部功能，必须校验密码！</span>
                    </div>
                    </div>
	              </td>
                </tr>
                
                <tr><td colspan="2" class="btns">
                <a class="btn  btn_next btn-primary">开始抓取</a></td></tr>
                </table>
                </form>
                
                </div>
            </div>
            <div id="tab-2" class="tab-pane panel2">
                <div class="panel-body">
                    <h2>即将上线，敬请期待</h2>
                </div>
            </div>
        </div>
    </div>
    
    </div>
    <%}%>
    
   
   